#![allow(non_snake_case)]

mod hackernews_post;
mod hackernews_state;
mod hackernews_async;

use dioxus::prelude::*;
use dioxus_logger::tracing::{info, Level};
use crate::hackernews_post::*;
use crate::hackernews_state::*;

fn main() {
    // Init logger
    dioxus_logger::init(Level::INFO).expect("failed to init logger");
    info!("starting app");

    // launch the app
    dioxus::launch(App); 
}

#[component]
fn App() -> Element {

    // must be invoked in a dioxus context
    // determines the initial value of the shared state and provides the value to all child components
    use_context_provider(|| Signal::new(PreviewState::Unset));

    rsx! {
        div { display: "flex", flex_direction: "row", width: "100%",
            div { width: "50%", Stories {} }
            div { width: "50%", Preview {} }
        }
    }
}
